package com.supor.aiot.mine.ui.setting;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.supor.aiot.common.app.Constants;
import com.supor.aiot.common.base.BaseMVVMActivity;
import com.supor.aiot.common.base.NoViewModel;
import com.supor.aiot.common.ui.activity.WebActivity;
import com.supor.aiot.mine.R;
import com.supor.aiot.mine.databinding.ActivityOneKeyLoginBinding;

public class OneKeyLoginActivity extends BaseMVVMActivity<NoViewModel, ActivityOneKeyLoginBinding> implements View.OnClickListener {

    private static final int TYPE = 1;
    // 中国移动隐私政策
    private static final String URL_CMCC = "https://wap.cmpassport.com/resources/html/contract.html";
    // 中国电信隐私政策
    private static final String URL_CT = "https://i.supor.com/tianyiAgreement.htm";
    // 中国联通隐私政策
    private static final String URL_CU = "https://opencloud.wostore.cn/authz/resource/html/disclaimer.html?fromsdk=true";

    @Override
    protected int resourceId() {
        return R.layout.activity_one_key_login;
    }

    @Override
    protected void initView() {
        super.initView();
        bindingView.toolbar.setIvLeftOnClickListener(v -> finish());
        bindingView.toolbar.setTvLeftOnClickListener(v -> finish());

        bindingView.rlOneKeyLoginCmcc.setOnClickListener(this);
        bindingView.rlOneKeyLoginCt.setOnClickListener(this);
        bindingView.rlOneKeyLoginCu.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        String title = getString(R.string.one_key_login_cu), url = URL_CU;
        if (id == R.id.rl_one_key_login_cmcc) {
            title = getString(R.string.one_key_login_cmcc);
            url = URL_CMCC;
        } else if (id == R.id.rl_one_key_login_ct) {
            title = getString(R.string.one_key_login_ct);
            url = URL_CT;
        }
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putInt(Constants.Key.param_type, TYPE);
        bundle.putString(Constants.Key.param_url, url);
        bundle.putString(Constants.Key.param_title, title);
        intent.putExtras(bundle);
        intent.setClass(this, WebActivity.class);
        startActivity(intent);
    }
}